package com.ruoyi.web.controller.order;

import com.ruoyi.order.service.IGoodsOrderComboInfoService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.order.domain.GoodsOrderComboInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 卖品订单套餐明细信息Controller
 *
 * @author HHAOYU
 * @date 2021-01-16
 */
@RestController
@RequestMapping("/order/goodsOrderComboInfo")
public class GoodsOrderComboInfoController extends BaseController
{
    @Autowired
    private IGoodsOrderComboInfoService goodsOrderComboInfoService;

    /**
     * 查询卖品订单套餐明细信息列表
     */
    @PreAuthorize("@ss.hasPermi('cinema:goodsOrderComboInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(GoodsOrderComboInfo goodsOrderComboInfo)
    {
        startPage();
        List<GoodsOrderComboInfo> list = goodsOrderComboInfoService.selectGoodsOrderComboInfoList(goodsOrderComboInfo);
        return getDataTable(list);
    }

    /**
     * 导出卖品订单套餐明细信息列表
     */
    @PreAuthorize("@ss.hasPermi('cinema:goodsOrderComboInfo:export')")
    @Log(title = "卖品订单套餐明细信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(GoodsOrderComboInfo goodsOrderComboInfo)
    {
        List<GoodsOrderComboInfo> list = goodsOrderComboInfoService.selectGoodsOrderComboInfoList(goodsOrderComboInfo);
        ExcelUtil<GoodsOrderComboInfo> util = new ExcelUtil<GoodsOrderComboInfo>(GoodsOrderComboInfo.class);
        return util.exportExcel(list, "goodsOrderComboInfo");
    }

    /**
     * 获取卖品订单套餐明细信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('cinema:goodsOrderComboInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(goodsOrderComboInfoService.selectGoodsOrderComboInfoById(id));
    }

    /**
     * 新增卖品订单套餐明细信息
     */
    @PreAuthorize("@ss.hasPermi('cinema:goodsOrderComboInfo:add')")
    @Log(title = "卖品订单套餐明细信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GoodsOrderComboInfo goodsOrderComboInfo)
    {
        return toAjax(goodsOrderComboInfoService.insertGoodsOrderComboInfo(goodsOrderComboInfo));
    }

    /**
     * 修改卖品订单套餐明细信息
     */
    @PreAuthorize("@ss.hasPermi('cinema:goodsOrderComboInfo:edit')")
    @Log(title = "卖品订单套餐明细信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GoodsOrderComboInfo goodsOrderComboInfo)
    {
        return toAjax(goodsOrderComboInfoService.updateGoodsOrderComboInfo(goodsOrderComboInfo));
    }

    /**
     * 删除卖品订单套餐明细信息
     */
    @PreAuthorize("@ss.hasPermi('cinema:goodsOrderComboInfo:remove')")
    @Log(title = "卖品订单套餐明细信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(goodsOrderComboInfoService.deleteGoodsOrderComboInfoByIds(ids));
    }
}
